package com;


/**
 * @author cyt
 * @create 2020-08-03 18:21
 */
public class AddNum {
    public static void main(String[] args) {

    }

    public static String addStrings(String num1, String num2) {
        StringBuilder builder = new StringBuilder();
        int carry = 0;
        int i = num1.length() - 1;
        int j = num2.length() - 1;
        while (i >= 0 || j >= 0 || carry != 0) {
            if (i >= 0) {
                carry += num1.charAt(i--) - '0';
            }
            if (j >= 0) {
                carry += num2.charAt(j--) - '0';
            }
            builder.append(carry % 10);
            carry /= 10;
        }
        return builder.reverse().toString();
    }

}
